﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:Panels="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.Panels"
             xmlns:Locals="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight"
             xmlns:Toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
             xmlns:fxui="clr-namespace:SilverlightFX.UserInterface;assembly=SilverlightFX"
             xmlns:fxtransitions="clr-namespace:SilverlightFX.UserInterface.Transitions;assembly=SilverlightFX"
             mc:Ignorable="d"
             xmlns:converter="clr-namespace:ASPItalia.ModelVirtualCasting.Silverlight.Converters"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             x:Class="ASPItalia.ModelVirtualCasting.Silverlight.MainPage"
             d:DesignHeight="588"
             d:DesignWidth="1000"
             Height="588"
             Width="1000">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
            </ResourceDictionary.MergedDictionaries>
            <converter:FirstImageConverter x:Key="FirstImageConverter" />
            <Style x:Key="DragDecoratorStyle1"
                   TargetType="Toolkit:DragDecorator">
                <Setter Property="Margin"
                        Value="0,4,0,0" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Toolkit:DragDecorator">
                            <Canvas>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal" />
                                        <VisualState x:Name="Disabled">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Duration="0"
                                                                               Storyboard.TargetProperty="Foreground"
                                                                               Storyboard.TargetName="Header">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <SolidColorBrush Color="#FF999999" />
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="EffectStates">
                                        <VisualState x:Name="Move">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                               Storyboard.TargetName="MoveImage">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Copy">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                               Storyboard.TargetName="CopyImage">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Link">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                               Storyboard.TargetName="LinkImage">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Scroll">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                               Storyboard.TargetName="ScrollImage">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="None">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                               Storyboard.TargetName="NoneImage">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Visibility>Visible</Visibility>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <ContentPresenter Cursor="{TemplateBinding Cursor}"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Content="{TemplateBinding Content}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  Margin="{TemplateBinding Margin}"
                                                  Opacity="0.25"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                <Grid Canvas.Left="{Binding IconPosition.X, RelativeSource={RelativeSource TemplatedParent}}"
                                      Canvas.Top="{Binding IconPosition.Y, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Border x:Name="MoveImage"
                                            BorderThickness="1"
                                            Visibility="Collapsed"
                                            VerticalAlignment="Top">
                                        <Canvas HorizontalAlignment="Left"
                                                Height="28">
                                            <Path Stroke="White"
                                                  Data="M32,12.959937 L16.536015,27.793268 L0.68184638,12.960436 z"
                                                  Height="19.972"
                                                  StrokeThickness="0.3"
                                                  StrokeLineJoin="Round"
                                                  UseLayoutRounding="False"
                                                  Width="42.65"
                                                  Canvas.Top="8"
                                                  Stretch="Fill">
                                                <Path.Fill>
                                                    <RadialGradientBrush Center="0.541,0.863"
                                                                         GradientOrigin="0.541,0.863"
                                                                         RadiusY="1.129"
                                                                         RadiusX="0.726">
                                                        <GradientStop Color="#FF32FF3C"
                                                                      Offset="0.383" />
                                                        <GradientStop Color="#00808080"
                                                                      Offset="1" />
                                                    </RadialGradientBrush>
                                                </Path.Fill>
                                            </Path>
                                        </Canvas>
                                    </Border>
                                    <Border x:Name="CopyImage"
                                            BorderThickness="1"
                                            Visibility="Collapsed"
                                            VerticalAlignment="Top">
                                        <StackPanel HorizontalAlignment="Left"
                                                    Orientation="Horizontal">
                                            <Path Data="F1 M 394.667,256.833L 405.333,256.833L 405.333,267.5L 416,267.5L 416,278.167L 405.333,278.167L 405.333,288.833L 394.667,288.833L 394.667,278.167L 384,278.167L 384,267.5L 394.667,267.5L 394.667,256.833 Z "
                                                  Height="8"
                                                  Stretch="Fill"
                                                  Stroke="#FFFFFFFF"
                                                  StrokeThickness="0.1"
                                                  StrokeLineJoin="Round"
                                                  UseLayoutRounding="False"
                                                  VerticalAlignment="Top"
                                                  Width="8">
                                                <Path.Effect>
                                                    <DropShadowEffect BlurRadius="8"
                                                                      Color="#FF000000"
                                                                      Direction="315"
                                                                      Opacity="0.6"
                                                                      ShadowDepth="1.51181" />
                                                </Path.Effect>
                                                <Path.Fill>
                                                    <LinearGradientBrush EndPoint="0.5,1"
                                                                         StartPoint="0.5,0">
                                                        <GradientStop Color="#FF0019A4"
                                                                      Offset="0" />
                                                        <GradientStop Color="#FF2B2956"
                                                                      Offset="1" />
                                                    </LinearGradientBrush>
                                                </Path.Fill>
                                            </Path>
                                        </StackPanel>
                                    </Border>
                                    <Border x:Name="LinkImage"
                                            BorderThickness="1"
                                            Visibility="Collapsed"
                                            VerticalAlignment="Top">
                                        <Path Data="F1 M924.995,614.00098 C946.44397,614.00098 965.31097,624.289 976.20599,639.84998 C987.12598,624.41699 1005.91,614.22998 1027.26,614.22998 C1060.99,614.22998 1076.9962,644.49744 1076.9962,675.88147 C1076.9962,707.26544 1060.99,727.88202 1027.26,727.88202 C1005.81,727.88202 986.94,717.59399 976.04401,702.03302 C965.125,717.466 946.33801,727.65198 924.995,727.65198 C891.26398,727.65198 863.91998,702.211 863.91998,670.82703 C863.91998,639.44299 891.26398,614.00098 924.995,614.00098 z M986.06897,670.82703 C986.06897,671.42603 986.06,672.02197 986.03998,672.617 C986.91998,693.09003 1005.04,709.43597 1027.26,709.43597 C1050.04,709.43597 1068.51,692.25299 1068.51,671.05603 C1068.51,649.85999 1050.04,632.677 1027.26,632.677 C1005.1,632.677 987.02899,648.92401 986.04797,669.31097 C986.06201,669.815 986.06897,670.32001 986.06897,670.82703 z M924.995,632.44702 C902.21301,632.44702 883.745,649.63 883.745,670.82703 C883.745,692.02301 902.21301,709.20697 924.995,709.20697 C947.14801,709.20697 965.22198,692.95801 966.20203,672.57001 C966.18799,672.06702 966.18103,671.56299 966.18103,671.05603 C966.18103,670.45801 966.19098,669.862 966.211,669.26801 C965.33197,648.79401 947.21503,632.44702 924.995,632.44702 z"
                                              Height="6"
                                              Stretch="Fill"
                                              Stroke="White"
                                              StrokeThickness="0.1"
                                              StrokeLineJoin="Round"
                                              UseLayoutRounding="False"
                                              Width="9.5">
                                            <Path.Effect>
                                                <DropShadowEffect BlurRadius="6"
                                                                  Color="#FF000000"
                                                                  Direction="315"
                                                                  Opacity="0.6"
                                                                  ShadowDepth="3.02362" />
                                            </Path.Effect>
                                            <Path.Fill>
                                                <LinearGradientBrush EndPoint="0.292808,2.1524"
                                                                     StartPoint="0.494361,-0.312728">
                                                    <GradientStop Color="#FFFF0000"
                                                                  Offset="0" />
                                                    <GradientStop Color="#FF000000"
                                                                  Offset="1" />
                                                </LinearGradientBrush>
                                            </Path.Fill>
                                        </Path>
                                    </Border>
                                    <Border x:Name="ScrollImage"
                                            BorderThickness="1"
                                            Visibility="Collapsed"
                                            VerticalAlignment="Top">
                                        <Path Data="M 0,5 L 10,5 L 5,0 M 0,8 L 10,8 L 5,13"
                                              HorizontalAlignment="Left"
                                              Stroke="Black">
                                            <Path.Effect>
                                                <DropShadowEffect BlurRadius="6"
                                                                  Color="#FF000000"
                                                                  Direction="315"
                                                                  Opacity="0.6"
                                                                  ShadowDepth="3.02362" />
                                            </Path.Effect>
                                            <Path.Fill>
                                                <LinearGradientBrush EndPoint="0.292808,2.1524"
                                                                     StartPoint="0.494361,-0.312728">
                                                    <GradientStop Color="#FF606060"
                                                                  Offset="0" />
                                                    <GradientStop Color="#FF000000"
                                                                  Offset="1" />
                                                </LinearGradientBrush>
                                            </Path.Fill>
                                        </Path>
                                    </Border>
                                    <Border x:Name="NoneImage"
                                            BorderThickness="1"
                                            Visibility="Collapsed"
                                            VerticalAlignment="Top">
                                        <Path Data="F1 M 690.086,484.334C 678.212,484.334 668.586,493.96 668.586,505.834C 668.586,517.708 678.212,527.334 690.086,527.334C 701.96,527.334 711.586,517.708 711.586,505.834C 711.586,493.96 701.961,484.334 690.086,484.334 Z M 690.086,491.313C 698.106,491.313 704.607,497.814 704.607,505.834C 704.607,508.82 703.706,511.595 702.161,513.903L 683.985,492.654C 685.84,491.793 687.907,491.313 690.086,491.313 Z M 690.086,520.355C 682.067,520.355 675.566,513.854 675.566,505.834C 675.566,502.605 676.62,499.622 678.403,497.21L 696.797,518.715C 694.79,519.763 692.507,520.355 690.086,520.355 Z "
                                              HorizontalAlignment="Left"
                                              Height="23.021"
                                              Stretch="Fill"
                                              Stroke="#FF960000"
                                              StrokeThickness="0.2"
                                              StrokeLineJoin="Round"
                                              Width="23"
                                              UseLayoutRounding="False">
                                            <Path.Fill>
                                                <LinearGradientBrush EndPoint="0.292808,2.1524"
                                                                     StartPoint="0.494361,-0.312728">
                                                    <GradientStop Color="#FFFF0000"
                                                                  Offset="0" />
                                                    <GradientStop Color="#FF000000"
                                                                  Offset="1" />
                                                </LinearGradientBrush>
                                            </Path.Fill>
                                        </Path>
                                    </Border>
                                </Grid>
                            </Canvas>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="ListBoxDragDropTargetStyle1"
                   TargetType="Toolkit:ListBoxDragDropTarget">
                <Setter Property="IsTabStop"
                        Value="false" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Toolkit:ListBoxDragDropTarget">
                            <Grid>
                                <ContentPresenter Cursor="{TemplateBinding Cursor}"
                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                  Content="{TemplateBinding Content}"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  Margin="{TemplateBinding Padding}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                <Canvas x:Name="InsertionIndicatorContainer"
                                        IsHitTestVisible="False">
                                    <Path x:Name="InsertionIndicator"
                                          IsHitTestVisible="False"
                                          Stroke="Gray"
                                          StrokeThickness="2" />
                                </Canvas>
                                <Popup x:Name="DragPopup"
                                       IsHitTestVisible="False">
                                    <Canvas x:Name="DragContainer"
                                            IsHitTestVisible="False">
                                        <Toolkit:DragDecorator x:Name="DragDecorator"
                                                               IsHitTestVisible="False"
                                                               Visibility="Collapsed"
                                                               Style="{StaticResource DragDecoratorStyle1}" />
                                    </Canvas>
                                </Popup>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>

    <!--  DataContext="{Binding Source={StaticResource ModelSampleDataSource}}"-->
    <Grid x:Name="LayoutRoot"
          MouseRightButtonDown="OnMouseRightButtonDown"
          MouseLeftButtonDown="LayoutRoot_MouseLeftButtonDown"
          Background="#FF333333">
        <Grid.RowDefinitions>
            <RowDefinition Height="0.345*" />
            <RowDefinition Height="0.655*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.5*" />
            <ColumnDefinition Width="0.5*" />
        </Grid.ColumnDefinitions>
        <Popup x:Name="RightMenu">
            <Border Background="#000000"
                    Padding="5">
                <StackPanel Width="155">
                    <Button Content="Richiesta informazioni"
                            Command="{Binding SendRequestFormCommand}"
                            Margin="5" Foreground="White" />
                    <Button Content="Stampa"
                            Command="{Binding PrintFormCommand}"
                            Margin="5" Foreground="White" />
                </StackPanel>
            </Border>
        </Popup>
        <fxui:ContentView x:Name="contentControl"
                          Content="{Binding SelectedItem.Multimedia, ElementName=modelListBox ,Converter={StaticResource FirstImageConverter}}"
                          HorizontalAlignment="Center"
                          Grid.RowSpan="2"
                          Grid.ColumnSpan="2">
            <fxui:ContentView.ContentTransition>
                <fxtransitions:CrossFade Duration="0:0:0.5" />
            </fxui:ContentView.ContentTransition>
            <fxui:ContentView.ContentTemplate>
                <DataTemplate>
                    <Image x:Name="modelImage"
                           Stretch="UniformToFill"
                           ImageFailed="modelImage_ImageFailed"
                           Source="{Binding }">
                        <Image.Effect>
                            <BlurEffect Radius="10" />
                        </Image.Effect>
                    </Image>
                </DataTemplate>
            </fxui:ContentView.ContentTemplate>

        </fxui:ContentView>
        <Path Data="M0,588.30591 L-1.006,451.03363 C-1.006,451.03363 179.00336,423.60223 492.94,427.15637 C727.33801,429.81003 1011.03,453.02322 1011.03,453.02322 L1007.006,587.66321 z"
              Grid.Row="1"
              Stretch="Fill"
              UseLayoutRounding="False"
              Grid.ColumnSpan="2"
              Margin="-1,0,-5,-1.969"
              VerticalAlignment="Bottom"
              Height="243.449">
            <Path.OpacityMask>
                <RadialGradientBrush Center="0.067,0.304"
                                     GradientOrigin="0.067,0.304"
                                     RadiusX="0.784">
                    <GradientStop Color="#26000000"
                                  Offset="0" />
                    <GradientStop Color="White"
                                  Offset="1" />
                </RadialGradientBrush>
            </Path.OpacityMask>
            <Path.Fill>
                <RadialGradientBrush Center="0.305,0.308"
                                     GradientOrigin="0.305,0.308"
                                     RadiusX="0.722">
                    <GradientStop Color="#FF333333"
                                  Offset="0.119" />
                    <GradientStop Color="Black"
                                  Offset="1" />
                </RadialGradientBrush>
            </Path.Fill>
        </Path>
        <Image x:Name="applicationLogo"
               HorizontalAlignment="Left"
               Source="/ASPItalia.ModelVirtualCasting.Silverlight;component/RawImage/Logo.png"
               Stretch="None"
               Width="197"
               VerticalAlignment="Top" />
        <Toolkit:ListBoxDragDropTarget  AllowDrop="true"
                                        Margin="65,0,0,50"
                                        Grid.Row="1"
                                        Style="{StaticResource ListBoxDragDropTargetStyle1}">
            <ListBox x:Name="modelListBox"
                     SelectionChanged="modelListBox_SelectionChanged"
                     Locals:DragManager.IsDragDock="True"
                     Locals:DragManager.FilterRightData="False"
                     Locals:DoubleClick.Command="{Binding ViewModelDetailsCommand}"
                     Style="{StaticResource ModelListBox}"
                     ItemsPanel="{StaticResource ModelsItemsPanelTemplate}"
                     ItemTemplate="{StaticResource FakeModelsItemTemplate}"
                     ItemsSource="{Binding ModelsList.View}"
                     Margin="0" />
        </Toolkit:ListBoxDragDropTarget >
        <Toolkit:ListBoxDragDropTarget  Margin="50,32,0,50"
                                        AllowDrop="true"
                                        Grid.Row="1"
                                        Grid.Column="1"
                                        VerticalAlignment="Bottom"
                                        HorizontalAlignment="Left">
            <ListBox  x:Name="selectedModelListBox"
                      Locals:DragManager.IsDragDock="True"
                      Locals:DragManager.FilterRightData="True"
                      ItemTemplate="{StaticResource SelectedModelItemtemplate}"
                      ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                      Style="{StaticResource SelectedModelListBox}"
                      ItemsSource="{Binding ModelsSelectedList.View, Mode=TwoWay}"
                      ItemsPanel="{StaticResource SelectedItemsPanelTemplate}" />
        </Toolkit:ListBoxDragDropTarget>

        <Locals:SearchControls Locals:DragManager.IsDraggable="true"
                               Locals:DragManager.FilterRightData="{Binding FilterRightData, Mode=TwoWay}"
                               d:LayoutOverrides="Width, Height"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center" />

        <TextBlock HorizontalAlignment="Left"
                   Grid.Row="1"
                   TextWrapping="Wrap"
                   Text="Modelle"
                   VerticalAlignment="Bottom"
                   RenderTransformOrigin="0,0"
                   Foreground="White"
                   FontFamily="Fonts/Fonts.zip#Segoe UI"
                   FontSize="40"
                   d:IsLocked="True">
        	<TextBlock.RenderTransform>
        		<TransformGroup>
        			<ScaleTransform />
        			<SkewTransform />
        			<RotateTransform Angle="-90" />
        			<TranslateTransform />
        		</TransformGroup>
        	</TextBlock.RenderTransform>
        </TextBlock>
        <TextBlock Foreground="White"
                   FontSize="40"
                   FontFamily="Fonts/Fonts.zip#Segoe UI"
                   HorizontalAlignment="Left"
                   Grid.Row="1"
                   RenderTransformOrigin="0,0"
                   TextWrapping="Wrap"
                   Text="Selezione"
                   VerticalAlignment="Bottom"
                   UseLayoutRounding="False"
                   d:LayoutRounding="Auto"
                   Grid.Column="1"
                   d:IsLocked="True">
        	<TextBlock.RenderTransform>
        		<TransformGroup>
        			<ScaleTransform />
        			<SkewTransform />
        			<RotateTransform Angle="-90" />
        			<TranslateTransform />
        		</TransformGroup>
        	</TextBlock.RenderTransform>
        </TextBlock>
        <StackPanel Grid.Column="1"
                    Orientation="Horizontal"
                    Grid.Row="1"
                    VerticalAlignment="Bottom"
                    d:LayoutOverrides="Width"
                    HorizontalAlignment="Center">
            <Button Content="Richiesta informazioni"
                    Command="{Binding SendRequestFormCommand}"
                    Margin="5,0" Foreground="White" Width="135" />
            <Button Content="Stampa"
                    Command="{Binding PrintFormCommand}"
                    Margin="5,0" Foreground="White" Width="135" />
        </StackPanel>
        <Grid Margin="-37,26,0,0"
              Grid.RowSpan="2"
              Grid.ColumnSpan="2">
            <Toolkit:BusyIndicator Content=""
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   IsBusy="{Binding ModelListLoading}"
                                   Width="200"
                                   Height="58"
                                   Style="{StaticResource BusyIndicatorStyle1}" />
        </Grid>

    </Grid>
</UserControl>
